<?php namespace web\admin\controller;
/** .-------------------------------------------------------------------
 * |  Software: [HDPHP framework]
 * |      Site: www.hdphp.com
 * |-------------------------------------------------------------------
 * |    Author: 向军 <2300071698@qq.com>
 * |    WeChat: aihoudun
 * | Copyright (c) 2012-2019, www.houdunwang.com. All Rights Reserved.
 * '-------------------------------------------------------------------*/

class Entry extends Common{
	//首页
	public function index() {
//		echo 1; die;
//		echo 2;die;
		View::make();
	}
	//h欢迎方法
public function welcome(){
	
	View::make();	
}
public function changePwd(){
	if(IS_POST){
		$oldPwd=Q('oldPwd','','md5');
		$newPwd1=Q('newPwd1','','md5');
		$newPwd2=Q('newPwd2','','md5');
//		var_dump($newPwd1);
//		var_dump($newpwd2);die;
	if($newPwd1!=$newPwd2){
		message('两次密码不一致');
	}
	//从数据库里面获取数据比对原来密码存不存在
	$model=new \system\model\User;
	$userdata=$model->where('uid',$_SESSION['id'])->first();
	if($userdata['password']!=$oldPwd){
		
		message('原密码不正确');
	}
	//新提交的秘码写入数据库
	$re=$model->where('uid',$_SESSION['id'])->update(array('password'=>$newPwd1));
	if(!$re){
		message('修改失败');
	}
//	将session清除
			session_unset();
			session_destroy();
//			注意如果在这里直接使用message跳转，那么，会使帧窗口跳转，效果有问题
//			message('修改成功',U('Login/login'));
			$url=U('Login/login');
			$str=<<<str
	<script type="text/javascript">
		alert('修改成功');
		parent.location.href="{$url}";
		
	</script>		
str;
			echo $str;die;
	}
	View::make();
}






}